package tongwentongshu.com.app.update;


import android.widget.TextView;

import java.util.Map;

import butterknife.BindView;
import retrofit2.http.Header;
import rx.Observable;
import tongwentongshu.com.app.R;
import tongwentongshu.com.app.network.NetworkApi;
import tongwentongshu.com.app.network.RetrofitServiceFactory;
import tongwentongshu.com.app.network.UseCase;

/**
 * Created by shiqiang on 2017/4/26.
 */

public class UpdateFractory extends UseCase {
    public Map<String, String> map;
    private NetworkApi appService;

    private String name;

    private static volatile UpdateFractory updateFractory;

    private UpdateFractory(String name, Map<String, String> map) {
        super();
        this.name = name;
        this.map = map;
        appService = RetrofitServiceFactory.getAppService();


    }

    private static UpdateFractory getUpdateFractory(String name, Map<String, String> map) {

        if (updateFractory == null) {

            updateFractory = new UpdateFractory(name, map);

        } else {

            updateFractory.setMap(name, map);

        }

        return updateFractory;

    }

    private void setMap(String name, Map<String, String> map) {

        this.name = name;
        this.map = map;
    }


    @Override
    protected Observable buildUseCaseObservable() {

        switch (this.name) {
            case "rqcordBook"://条形码查询
                return appService.rqcordBook(map);
            case "PioCall"://得到地图标点
                return appService.PioCall(map);
            case "BookListCall"://得到aoi点所有书籍
                return appService.BookListCall(map);
            case "ReleaseBookCall":
                return appService.ReleaseBookCall(map);
            case "BookTypeListCall":
                return appService.BookTypeListCall(map);
            case "SendRegCodeCall":
                return appService.SendRegCodeCall(map);
            case "BookdetailCall":
                return appService.BookdetailCall(map);
            case "RegisteredCall":
                return appService.RegisteredCall(map);
            case "CheckNameCall":
                return appService.CheckNameCall(map);
            case "SendCodCall":
                return appService.SendCodCall(map);
            case "ResetPwdCall":
                return appService.ResetPwdCall(map);
            case "ModifyPwdCall":
                return appService.ModifyPwdCall(map);
            case "EditPersonCall":
                return appService.EditPersonCall(map);
            case "LoginCall":
                return appService.LoginCall(map);
            case "MyReadingCall":
                return appService.MyReadingCall(map);
            case "MyCollectionCall":
                return appService.MyCollectionCall(map);
            case "MyShareCall":
                return appService.MyShareCall(map);
            case "MyFollowCall":
                return appService.MyFollowCall(map);
            case "PersonalShowCall":
                return appService.PersonalShowCall(map);
            case "MyShareDetailCall":
                return appService.MyShareDetailCall(map);
            case "OperationBookCall":
                return appService.OperationBookCall(map);
            case "SigninCall":
                return appService.SigninCall(map);
            case "WalletCall":
                return appService.WalletCall(map);
            case "DoudouDetailCall":
                return appService.DoudouDetailCall(map);
            case "MoneyDetailCall":
                return appService.MoneyDetailCall(map);
            case "BackMoneyCall":
                return appService.BackMoneyCall(map);
            case "AddmyCollectionCall":
                return appService.AddmyCollectionCall(map);
            case "AddmyFollowCall":
                return appService.AddmyFollowCall(map);
            case "AgainReleaseBookCall":
                return appService.AgainReleaseBookCall(map);
            case "MyProblemHelpCall":
                return appService.MyProblemHelpCall(map);
            case "UserPayCall":
                return appService.UserPayCall(map);
            case "MessageReadCall":
                return appService.MessageReadCall(map);
            case "MessageListCall":
                return appService.MessageListCall(map);
            case "BookSearchCall":
                return appService.BookSearchCall(map);
            case "CancelTypelistCall":
                return appService.CancelTypelistCall(map);
            case "VersionCall":
                return appService.VersionCall(map);
            case "UseravatarCall":
                return appService.UseravatarCall(map);
            case "SuggestTypeCall":
                return appService.SuggestTypeCall(map);
            case "suggestEditCall":
                return appService.suggestEditCall(map);
            case "UpdateMessageCall":
                return appService.UpdateMessageCall(map);
            case "SetallmessageCall":
                return appService.SetallmessageCall(map);
            case "WithdrawalsInfoCall":
                return appService.WithdrawalsInfoCall(map);
            case "WithdrawalsCall":
                return appService.WithdrawalsCall(map);

        }


        return null;
    }


    public static Build getBuild() {

        return Build.getBuild();
    }


    public static class Build {


        private Build() {
        }

        private static final Build single = new Build();

        public static Build getBuild() {

            return single;

        }

        private Map<String, String> map;
        private String name;

        public Build map(Map<String, String> map) {
            this.map = map;
            return this;
        }


        public Build name(String name) {
            this.name = name;
            return this;
        }

        public UseCase build() {

            return UpdateFractory.getUpdateFractory(this.name, this.map);
        }


    }


}
